package com.example.musicdemo.util

import android.view.MenuItem
import android.widget.Toast
import androidx.appcompat.widget.Toolbar
import androidx.appcompat.widget.Toolbar.OnMenuItemClickListener
import com.example.musicdemo.R
import com.example.musicdemo.ui.activity.MainActivity

/**
 * Description: 所有toolbar的管理类
 */
interface ToolBarManager {
    val toolbar:Toolbar

    /**
     * 初始化主界面的toolbar
     */
    fun initMainToolBar(){
        toolbar.setTitle("淦淦影音")

        toolbar.inflateMenu(R.menu.main)

        toolbar.setOnMenuItemClickListener(object : OnMenuItemClickListener{
            override fun onMenuItemClick(item: MenuItem?): Boolean {
                when(item?.itemId){
                    R.id.item_setting->{
                        Toast.makeText(toolbar.context, "点击了setting", Toast.LENGTH_SHORT).show()
                    }
                }
                return true
            }
        })

    }
}